package com.idata.model.enums;

import com.idata.model.proxyDO.CollaborativeCaseDO;
import com.idata.model.proxyDO.Police110CaseDO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.lang.Nullable;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @File CaseType.Java
 * @Modify Time      @Author    @Version    @Description
 * ------------      -------    --------    -----------
 * 2023/10/11         yd.j      1.0         None
 */

@Getter
@AllArgsConstructor
public enum DisputeSourceEnum {

    POLICE_110(1, "110警情", Police110CaseDO.class),
    COLLABORATIVE_CASE(2, "协同办案", CollaborativeCaseDO.class),

    HIGH_RISK(3, "高危", Objects.class),
    ;

    private final Integer code;
    private final String desc;
    private final Class<?> clazz;

    private static final Map<Integer, DisputeSourceEnum> VALUES_FOR_CODE = new HashMap<>();
    private static final Map<String, DisputeSourceEnum> DESC_FOR_CODE = new HashMap<>();

    static {
        for (DisputeSourceEnum disputeSourceEnum : DisputeSourceEnum.values()) {
            VALUES_FOR_CODE.put(disputeSourceEnum.getCode(), disputeSourceEnum);
            DESC_FOR_CODE.put(disputeSourceEnum.getDesc(), disputeSourceEnum);
        }
    }


    @Nullable
    public static DisputeSourceEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        return VALUES_FOR_CODE.get(code);
    }

    @Nullable
    public static DisputeSourceEnum fromDesc(String desc) {
        if (desc == null) {
            return null;
        }
        return DESC_FOR_CODE.get(desc);
    }

}
